﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TestDemo04
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            // 通过包装的属性设置按钮的背景颜色
            btn_ButtonC.Background = new SolidColorBrush(Colors.Red);
            // 通过依赖性属性的SetValue设置按钮的背景颜色
            SolidColorBrush brush = new SolidColorBrush(Colors.Blue);
            btn_ButtonD.SetValue(Button.BackgroundProperty, brush);
            // 通过包装的属性获取ButtonB的背景颜色
            SolidColorBrush b_Brush1 = (SolidColorBrush)(btn_ButtonB.Background);
            txt_Value1.Text = b_Brush1.Color.ToString();
            // 通过依赖性属性的GetValue获取ButtonB的背景颜色
            SolidColorBrush b_Brush2 = (SolidColorBrush)(btn_ButtonB.GetValue(
                Button.BackgroundProperty
                ));
            txtValue2.Text = b_Brush2.Color.ToString();
        }
    }
}
